home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
psmem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-07
|
42KB
|
1,483 lines
/*
* @(#) psmem.c 12.1 95/07/07 SCOINC
*/
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* Modification History
*
* S002, 25-Oct-93, rickra
* Fixed some new compiler warnings.....
*
* S001, 15-Sep-93, rickra
* Removed sort order on a per VIEW basis...
* Fixed little bugs here and there...
*
* S000, 27-May-93, rickra
* Added support for the VIEW....
*/
/*+-------------------------------------------------------------------------
psmem.c - XSW PS MEM status detail
Defined functions:
--------------------------------------------------------------------------*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/DrawingA.h>
#include "include/unixincs.h"
#include "include/resources.h"
#include "include/xswboth.h"
#include "include/buttons.h"
#include "include/libkmem.h"
#include "include/libmem.h"
#include "include/libswap.h"
#include "include/xsw.h"
#include "include/psmem.h"
extern struct NetworkXswStruct *current_server;
#define MEM_UID_X 0
#define MEM_PID_X 10
#define MEM_VSIZE_X 18
#define MEM_SHRD_X 25
#define MEM_PRIV_X 31
#define MEM_WTD_X 37
#define MEM_TOTAL_X 43
#define MEM_SWAP_X 49
#define MEM_FILE_X 57
/*+-------------------------------------------------------------------------
process_mem_user_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_user_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (strcmp (ppp2 -> name, ppp1 -> name));
else
return (strcmp (ppp1 -> name, ppp2 -> name));
} /* end of process_io_user_compare */
/*+-------------------------------------------------------------------------
process_mem_pid_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_pid_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> p_pid - ppp1 -> p_pid);
else
return (ppp1 -> p_pid - ppp2 -> p_pid);
} /* end of process_mem_pid_compare */
/*+-------------------------------------------------------------------------
process_mem_vsize_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_vsize_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> virtual - ppp1 -> virtual);
else
return (ppp1 -> virtual - ppp2 -> virtual);
} /* end of process_mem_vsize_compare */
/*+-------------------------------------------------------------------------
process_mem_shrd_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_shrd_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> shared - ppp1 -> shared);
else
return (ppp1 -> shared - ppp2 -> shared);
} /* end of process_mem_shrd_compare */
/*+-------------------------------------------------------------------------
process_mem_priv_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_priv_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> private - ppp1 -> private);
else
return (ppp1 -> private - ppp2 -> private);
} /* end of process_mem_priv_compare */
/*+-------------------------------------------------------------------------
process_mem_wtd_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_wtd_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> weighted - ppp1 -> weighted);
else
return (ppp1 -> weighted - ppp2 -> weighted);
} /* end of process_mem_wtd_compare */
/*+-------------------------------------------------------------------------
process_memory_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_memory_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> total - ppp1 -> total);
else
return (ppp1 -> total - ppp2 -> total);
} /* end of process_memory_compare */
/*+-------------------------------------------------------------------------
process_mem_cmd_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_cmd_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
int i, j;
if (current_server -> ps_mem_sort_order == 1)
return (strcmp (ppp2 -> u_psargs, ppp1 -> u_psargs));
else
return (strcmp (ppp1 -> u_psargs, ppp2 -> u_psargs));
} /* end of process_mem_cmd_compare */
/*+-------------------------------------------------------------------------
process_mem_none_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_none_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> none - ppp1 -> none);
else
return (ppp1 -> none - ppp2 -> none);
} /* end of process_mem_none_compare */
/*+-------------------------------------------------------------------------
process_mem_swap_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_swap_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> swap - ppp1 -> swap);
else
return (ppp1 -> swap - ppp2 -> swap);
} /* end of process_mem_swap_compare */
/*+-------------------------------------------------------------------------
process_mem_file_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_file_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> file - ppp1 -> file);
else
return (ppp1 -> file - ppp2 -> file);
} /* end of process_mem_file_compare */
/*+-------------------------------------------------------------------------
process_mem_lstfile_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_lstfile_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> lstfile - ppp1 -> lstfile);
else
return (ppp1 -> lstfile - ppp2 -> lstfile);
} /* end of process_mem_lstfile_compare */
/*+-------------------------------------------------------------------------
process_mem_zero_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_zero_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> zero - ppp1 -> zero);
else
return (ppp1 -> zero - ppp2 -> zero);
} /* end of process_mem_zero_compare */
/*+-------------------------------------------------------------------------
process_mem_fill_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_fill_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> fill - ppp1 -> fill);
else
return (ppp1 -> fill - ppp2 -> fill);
} /* end of process_mem_fill_compare */
#ifdef XSW32v5
#define iomap proc
#endif
/*+-------------------------------------------------------------------------
process_mem_iomap_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_iomap_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> iomap - ppp1 -> iomap);
else
return (ppp1 -> iomap - ppp2 -> iomap);
} /* end of process_mem_iomap_compare */
/*+-------------------------------------------------------------------------
process_mem_window_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
#ifndef XSW32v5
process_mem_window_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> window - ppp1 -> window);
else
return (ppp1 -> window - ppp2 -> window);
} /* end of process_mem_window_compare */
#endif
/*+-------------------------------------------------------------------------
process_mem_swap_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_swap_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> swap_core - ppp1 -> swap_core);
else
return (ppp1 -> swap_core - ppp2 -> swap_core);
} /* end of process_mem_swap_core_compare */
/*+-------------------------------------------------------------------------
process_mem_file_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_file_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> file_core - ppp1 -> file_core);
else
return (ppp1 -> file_core - ppp2 -> file_core);
} /* end of process_mem_file_core_compare */
/*+-------------------------------------------------------------------------
process_mem_lstfile_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_lstfile_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (ppp2 -> lstfile_core - ppp1 -> lstfile_core);
else
return (ppp1 -> lstfile_core - ppp2 -> lstfile_core);
} /* end of process_mem_lstfile_core_compare */
/*+-------------------------------------------------------------------------
process_mem_swap_not_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_swap_not_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return ((ppp2 -> swap - ppp2 -> swap_core) -
(ppp1 -> swap - ppp1 -> swap_core));
else
return ((ppp1 -> swap - ppp1 -> swap_core) -
(ppp2 -> swap - ppp2 -> swap_core));
} /* end of process_mem_swap_not_core_compare */
/*+-------------------------------------------------------------------------
process_mem_file_not_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_file_not_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return ((ppp2 -> file - ppp2 -> file_core) -
(ppp1 -> file - ppp1 -> file_core));
else
return ((ppp1 -> file - ppp1 -> file_core) -
(ppp2 -> file - ppp2 -> file_core));
} /* end of process_mem_file_not_core_compare */
/*+-------------------------------------------------------------------------
process_mem_lstfile_not_core_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_lstfile_not_core_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return ((ppp2 -> lstfile - ppp2 -> lstfile_core) -
(ppp1 -> lstfile - ppp1 -> lstfile_core));
else
return ((ppp1 -> lstfile - ppp1 -> lstfile_core) -
(ppp2 -> lstfile - ppp2 -> lstfile_core));
} /* end of
*
*
* process_mem_lstfile_not_core_compare */
/*+-------------------------------------------------------------------------
process_mem_core_dbd_compare(ppp1,ppp2)
--------------------------------------------------------------------------*/
process_mem_core_dbd_compare (ppp1, ppp2)
register process_memory *ppp1;
register process_memory *ppp2;
{
if (current_server -> ps_mem_sort_order == 1)
return (
(ppp2 -> none + ppp2 -> swap_core + ppp2 -> file_core + ppp2 -> lstfile_core) -
(ppp1 -> none + ppp1 -> swap_core + ppp1 -> file_core + ppp1 -> lstfile_core));
else
return (
(ppp1 -> none + ppp1 -> swap_core + ppp1 -> file_core + ppp1 -> lstfile_core) -
(ppp2 -> none + ppp2 -> swap_core + ppp2 -> file_core + ppp2 -> lstfile_core));
} /* end of process_mem_lstfile_compare */
/*+-------------------------------------------------------------------------
read_memory_stats(SP)
struct NetworkXswStruct *SP;
--------------------------------------------------------------------------*/
void
read_memory_stats (SP)
struct NetworkXswStruct *SP;
{
register int iproc;
preg_t *mypregion = NULL;
preg_t *start_mypregion = NULL;
process_memory *memory_pointer = NULL;
struct my_proc_struct *mytproc = NULL;
struct region myregion;
int unused = 0;
int got_data = 0;
int virtual_size = 0;
int private_mem = 0;
int shared_mem = 0;
int weighted = 0;
int i;
int j;
int num_regions = 0;
int temp_data;
/*
fprintf(stdout,"in read_memory_stats\n");
*/
if (SP-> heap_memory_pointer != NULL)
{
if (SP-> memory_state != NULL)
{
/*
fprintf(stdout,"freeing memory_state\n");
*/
free (SP-> memory_state);
}
SP -> memory_state = SP -> new_memory_state;
SP -> current_mem_procs_bak =
SP -> current_mem_procs;
/*
fprintf(stdout,"SP -> current_mem_procs_bak =%d\n",
SP -> current_mem_procs);
*/
SP -> num_active_process = 0;
SP -> current_mem_procs = 0;
/*
fprintf(stdout,"in read_memory_stats1\n");
*/
if (SP -> memory_pointer_bak != NULL)
{
/*
fprintf(stdout,"freeing SP -> memory_pointer_bak\n");
*/
free (SP -> memory_pointer_bak);
}
SP -> memory_pointer_bak = (process_memory_bak *)
calloc (SP -> current_mem_procs_bak,
sizeof (process_memory_bak));
/*
fprintf(stdout,"in read_memory_stats2\n");
*/
if (SP -> memory_pointer_bak == NULL)
{
disp_msg (colorDisplayMsg.pixel, "COULD NOT MALLOC for PS_MEM 5");
}
/* should use memcpy for this */
/*
fprintf(stdout,"in read_memory_stats3\n");
*/
if ((SP -> memory_pointer_bak != NULL) &&
(SP -> heap_memory_pointer != NULL))
for (i = 0; i < SP -> current_mem_procs_bak; i++)
{
SP -> memory_pointer_bak[i].p_pid =
SP -> heap_memory_pointer[i].p_pid;
SP -> memory_pointer_bak[i].total_1 =
SP -> heap_memory_pointer[i].total;
SP -> memory_pointer_bak[i].virtual =
SP -> heap_memory_pointer[i].virtual;
SP -> memory_pointer_bak[i].shared =
SP -> heap_memory_pointer[i].shared;
SP -> memory_pointer_bak[i].private =
SP -> heap_memory_pointer[i].private;
SP -> memory_pointer_bak[i].weighted =
SP -> heap_memory_pointer[i].weighted;
SP -> memory_pointer_bak[i].none =
SP -> heap_memory_pointer[i].none;
SP -> memory_pointer_bak[i].swap =
SP -> heap_memory_pointer[i].swap;
SP -> memory_pointer_bak[i].file =
SP -> heap_memory_pointer[i].file;
SP -> memory_pointer_bak[i].lstfile =
SP -> heap_memory_pointer[i].lstfile;
SP -> memory_pointer_bak[i].swap_core =
SP -> heap_memory_pointer[i].swap_core;
SP -> memory_pointer_bak[i].file_core =
SP -> heap_memory_pointer[i].file_core;
SP -> memory_pointer_bak[i].lstfile_core =
SP -> heap_memory_pointer[i].lstfile_core;
SP -> memory_pointer_bak[i].zero =
SP -> heap_memory_pointer[i].zero;
SP -> memory_pointer_bak[i].fill =
SP -> heap_memory_pointer[i].fill;
SP -> memory_pointer_bak[i].iomap =
SP -> heap_memory_pointer[i].iomap;
#ifndef XSW32v5
SP -> memory_pointer_bak[i].window =
SP -> heap_memory_pointer[i].window;
#endif
}
if (SP -> heap_memory_pointer != NULL)
free (SP -> heap_memory_pointer);
SP -> got_memory_state = 1;
}
/*
* Ask for memory process data....
*/
xsw_write (SP,
SP -> FileDescriptor,
send_mem_process_data,
sizeof (int));
xsw_read (SP,
SP -> FileDescriptor,
&SP -> current_mem_procs,
sizeof (int));
xsw_write (SP,
SP -> FileDescriptor,
&got_data,
sizeof (int));
SP -> heap_memory_pointer = (process_memory *)
calloc (SP -> current_mem_procs,
sizeof (process_memory));
/*
fprintf(stdout,"new current_mem_procs = %d\n",
SP -> current_mem_procs);
*/
xsw_read (SP,
SP -> FileDescriptor,
SP -> heap_memory_pointer,
sizeof (process_memory) * SP -> current_mem_procs);
SP -> num_active_process = SP -> current_mem_procs;
SP -> new_memory_state = (int *) calloc (
SP -> current_mem_procs,
sizeof (int));
}
/*
* assign_ps_mem_pixels (SP, i, j)
*
* Assign colors for each memory type....
*
*/
struct ps_mem_pixel_struct *
assign_ps_mem_pixels (SP, i, j)
struct NetworkXswStruct *SP;
int i;
int j;
{
struct ps_mem_pixel_struct *pixel_list;
pixel_list = (struct ps_mem_pixel_struct *)
calloc (1, sizeof (struct ps_mem_pixel_struct));
if ( (ushort) (SP -> memory_pointer_bak[j].virtual) <
(ushort) (SP -> heap_memory_pointer[i].virtual) )
pixel_list -> virtual_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].virtual) >
(ushort) (SP -> heap_memory_pointer[i].virtual) )
pixel_list -> virtual_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> virtual_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].shared) <
(ushort) (SP -> heap_memory_pointer[i].shared) )
pixel_list -> shared_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].shared) >
(ushort) (SP -> heap_memory_pointer[i].shared) )
pixel_list -> shared_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> shared_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].private) <
(ushort) (SP -> heap_memory_pointer[i].private) )
pixel_list -> private_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].private) >
(ushort) (SP -> heap_memory_pointer[i].private) )
pixel_list -> private_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> private_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].weighted) <
(ushort) (SP -> heap_memory_pointer[i].weighted) )
pixel_list -> weighted_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].weighted) >
(ushort) (SP -> heap_memory_pointer[i].weighted) )
pixel_list -> weighted_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> weighted_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].total_1) <
(ushort) (SP -> heap_memory_pointer[i].total) )
pixel_list -> total_1_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].total_1) >
(ushort) (SP -> heap_memory_pointer[i].total) )
pixel_list -> total_1_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> total_1_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].none) <
(ushort) (SP -> heap_memory_pointer[i].none) )
pixel_list -> none_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].none) >
(ushort) (SP -> heap_memory_pointer[i].none) )
pixel_list -> none_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> none_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].swap_core) <
(ushort) (SP -> heap_memory_pointer[i].swap_core) )
pixel_list -> swap_core_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].swap_core) >
(ushort) (SP -> heap_memory_pointer[i].swap_core) )
pixel_list -> swap_core_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> swap_core_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].file_core) <
(ushort) (SP -> heap_memory_pointer[i].file_core) )
pixel_list -> file_core_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].file_core) >
(ushort) (SP -> heap_memory_pointer[i].file_core) )
pixel_list -> file_core_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> file_core_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].lstfile_core) <
(ushort) (SP -> heap_memory_pointer[i].lstfile_core) )
pixel_list -> lstfile_core_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].lstfile_core) >
(ushort) (SP -> heap_memory_pointer[i].lstfile_core) )
pixel_list -> lstfile_core_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> lstfile_core_pixel = colorPSmem.pixel;
if ((ushort) (
SP -> memory_pointer_bak[j].none +
SP -> memory_pointer_bak[j].swap_core +
SP -> memory_pointer_bak[j].file_core +
SP -> memory_pointer_bak[j].lstfile_core) <
(ushort) (
SP -> heap_memory_pointer[i].none +
SP -> heap_memory_pointer[i].swap_core +
SP -> heap_memory_pointer[i].file_core +
SP -> heap_memory_pointer[i].lstfile_core))
pixel_list -> total_2_pixel = colorPSmemGrowing.pixel;
else if ((ushort)(
SP -> memory_pointer_bak[j].none +
SP -> memory_pointer_bak[j].swap_core +
SP -> memory_pointer_bak[j].file_core +
SP -> memory_pointer_bak[j].lstfile_core) >
(ushort) (
SP -> heap_memory_pointer[i].none +
SP -> heap_memory_pointer[i].swap_core +
SP -> heap_memory_pointer[i].file_core +
SP -> heap_memory_pointer[i].lstfile_core))
pixel_list -> total_2_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> total_2_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].swap) <
(ushort) (SP -> heap_memory_pointer[i].swap) )
pixel_list -> swap_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].swap) >
(ushort) (SP -> heap_memory_pointer[i].swap) )
pixel_list -> swap_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> swap_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].file) <
(ushort) (SP -> heap_memory_pointer[i].file) )
pixel_list -> file_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].file) >
(ushort) (SP -> heap_memory_pointer[i].file) )
pixel_list -> file_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> file_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].lstfile) <
(ushort) (SP -> heap_memory_pointer[i].lstfile) )
pixel_list -> lstfile_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].lstfile) >
(ushort) (SP -> heap_memory_pointer[i].lstfile) )
pixel_list -> lstfile_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> lstfile_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].zero) <
(ushort) (SP -> heap_memory_pointer[i].zero) )
pixel_list -> zero_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].zero) >
(ushort) (SP -> heap_memory_pointer[i].zero) )
pixel_list -> zero_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> zero_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].fill) <
(ushort) (SP -> heap_memory_pointer[i].fill) )
pixel_list -> fill_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].fill) >
(ushort) (SP -> heap_memory_pointer[i].fill) )
pixel_list -> fill_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> fill_pixel = colorPSmem.pixel;
if ((ushort) (SP -> memory_pointer_bak[j].iomap) <
(ushort) (SP -> heap_memory_pointer[i].iomap) )
pixel_list -> iomap_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].iomap) >
(ushort) (SP -> heap_memory_pointer[i].iomap) )
pixel_list -> iomap_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> iomap_pixel = colorPSmem.pixel;
#ifndef XSW32v5
if ((ushort) (SP -> memory_pointer_bak[j].window) <
(ushort) (SP -> heap_memory_pointer[i].window) )
pixel_list -> window_pixel = colorPSmemGrowing.pixel;
else if ((ushort) (SP -> memory_pointer_bak[j].window) >
(ushort) (SP -> heap_memory_pointer[i].window) )
pixel_list -> window_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> window_pixel = colorPSmem.pixel;
#endif
if ((ushort) (
SP -> memory_pointer_bak[j].swap -
SP -> memory_pointer_bak[j].swap_core) <
(ushort) (
SP -> heap_memory_pointer[i].swap -
SP -> heap_memory_pointer[i].swap_core))
pixel_list -> swap_only_pixel = colorPSmemGrowing.pixel;
else if ((ushort)(
SP -> memory_pointer_bak[j].swap -
SP -> memory_pointer_bak[j].swap_core) >
(ushort)(
SP -> heap_memory_pointer[i].swap -
SP -> heap_memory_pointer[i].swap_core))
pixel_list -> swap_only_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> swap_only_pixel = colorPSmem.pixel;
if ((ushort)(
SP -> memory_pointer_bak[j].file -
SP -> memory_pointer_bak[j].file_core) <
(ushort)(
SP -> heap_memory_pointer[i].file -
SP -> heap_memory_pointer[i].file_core))
pixel_list -> file_only_pixel = colorPSmemGrowing.pixel;
else if ((ushort)(
SP -> memory_pointer_bak[j].file -
SP -> memory_pointer_bak[j].file_core) >
(ushort)(
SP -> heap_memory_pointer[i].file -
SP -> heap_memory_pointer[i].file_core))
pixel_list -> file_only_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> file_only_pixel = colorPSmem.pixel;
if ((ushort)(
SP -> memory_pointer_bak[j].lstfile -
SP -> memory_pointer_bak[j].lstfile_core) <
(ushort)(
SP -> heap_memory_pointer[i].lstfile -
SP -> heap_memory_pointer[i].lstfile_core))
pixel_list -> lstfile_only_pixel = colorPSmemGrowing.pixel;
else if ((ushort)(
SP -> memory_pointer_bak[j].lstfile -
SP -> memory_pointer_bak[j].lstfile_core) >
(ushort)(
SP -> heap_memory_pointer[i].lstfile -
SP -> heap_memory_pointer[i].lstfile_core))
pixel_list -> lstfile_only_pixel = colorPSmemShrinking.pixel;
else
pixel_list -> lstfile_only_pixel = colorPSmem.pixel;
return (pixel_list);
}
struct ps_mem_pixel_struct *
determine_ps_mem_pixel (SP, i)
struct NetworkXswStruct *SP;
int i;
{
int j = 0;
int found_pid = 0;
struct ps_mem_pixel_struct *pixel_list;
if (SP -> memory_pointer_bak != NULL)
{
if ((i < SP -> current_mem_procs_bak) &&
(SP -> memory_pointer_bak[i].p_pid == SP -> heap_memory_pointer[i].p_pid))
{
j = i;
found_pid = 1;
pixel_list = assign_ps_mem_pixels (SP, i, i);
}
else
for (j = 0; j < SP -> current_mem_procs_bak; j++)
{
if (SP -> memory_pointer_bak[j].p_pid ==
SP -> heap_memory_pointer[i].p_pid)
{
found_pid = 1;
pixel_list = assign_ps_mem_pixels (SP, i, j);
break;
}
}
if (found_pid == 0)
{
pixel_list = (struct ps_mem_pixel_struct *)
calloc (1, sizeof (struct ps_mem_pixel_struct));
pixel_list -> virtual_pixel = colorPSmemNew.pixel;
pixel_list -> shared_pixel = colorPSmemNew.pixel;
pixel_list -> private_pixel = colorPSmemNew.pixel;
pixel_list -> weighted_pixel = colorPSmemNew.pixel;
pixel_list -> total_1_pixel = colorPSmemNew.pixel;
pixel_list -> none_pixel = colorPSmemNew.pixel;
pixel_list -> swap_core_pixel = colorPSmemNew.pixel;
pixel_list -> file_core_pixel = colorPSmemNew.pixel;
pixel_list -> lstfile_core_pixel = colorPSmemNew.pixel;
pixel_list -> total_2_pixel = colorPSmemNew.pixel;
pixel_list -> swap_pixel = colorPSmemNew.pixel;
pixel_list -> file_pixel = colorPSmemNew.pixel;
pixel_list -> lstfile_pixel = colorPSmemNew.pixel;
pixel_list -> zero_pixel = colorPSmemNew.pixel;
pixel_list -> fill_pixel = colorPSmemNew.pixel;
pixel_list -> iomap_pixel = colorPSmemNew.pixel;
pixel_list -> window_pixel = colorPSmemNew.pixel;
pixel_list -> swap_only_pixel = colorPSmemNew.pixel;
pixel_list -> file_only_pixel = colorPSmemNew.pixel;
pixel_list -> lstfile_only_pixel = colorPSmemNew.pixel;
}
}
return (pixel_list);
}
/*+-------------------------------------------------------------------------
update_ps_mem( SP )
--------------------------------------------------------------------------*/
void
update_ps_mem (SP)
struct NetworkXswStruct *SP;
{
Window window = SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].window;
Display *display = SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].display;
GC gc = SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].gc;
XWindowAttributes DrawAreaXYWH = SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].DrawAreaXYWH;
Pixmap pixmap = SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].pixmap;
char s256[256];
unsigned long pixel;
struct ps_mem_pixel_struct *pixel_list = NULL;
int found_pid = 0;
int mem_state = 0;
int j = 0;
int x = 0;
int y = 0;
int i = 0;
int k = 0;
int fheight = FHEIGHT;
int x1 = 0;
int x2 = 0;
int drawn_number = 0;
sort_procs (BUTTON_ps_mem);
for (i = 0; i < SP -> num_active_process; i++)
{
x1 = 0;
x2 = 0;
pixel = colorPSmem.pixel;
/*
* Lets do a little filtering......
*/
if ((((SP -> ps_mem_screen_mode == 1) ||
(SP -> ps_mem_screen_mode == 2)) &&
(SP -> heap_memory_pointer[i].total > 0)
) ||
(SP -> ps_mem_screen_mode == 4) ||
(SP -> ps_mem_screen_mode == 3)
)
{
y = drawn_number * fheight;
drawn_number++;
/*
* Clear the enitre line
*/
XSetForeground (display, gc, background);
XFillRectangle (display, pixmap, gc, x, y,
SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].draw_width - x,
FHEIGHT);
switch (SP -> ps_mem_screen_mode)
{
case 1:
/*
* Display Name & Pid
*/
pixel_list = determine_ps_mem_pixel (SP, i);
x1 = sprintf (s256,
"%9s %5d ",
SP -> heap_memory_pointer[i].name,
SP -> heap_memory_pointer[i].p_pid);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Virtual
*/
x1 = sprintf (s256, "%6d ",
SP -> heap_memory_pointer[i].virtual);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> virtual_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Shared
*/
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].shared);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> shared_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Private
*/
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].private);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> private_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Weighted
*/
x1 = sprintf (s256, "%4d ",
SP -> heap_memory_pointer[i].weighted);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> weighted_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Total
*/
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].total);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> total_1_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Command
*/
x1 = sprintf (s256, "%s ",
SP -> heap_memory_pointer[i].u_psargs);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
break;
case 2:
/*
* Display Name & Pid
*/
pixel_list = determine_ps_mem_pixel (SP, i);
x1 = sprintf (s256,
"%9s %5d ",
SP -> heap_memory_pointer[i].name,
SP -> heap_memory_pointer[i].p_pid);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Virtual
*/
x1 = sprintf (s256, "%6d ",
SP -> heap_memory_pointer[i].virtual);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> virtual_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].none);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> none_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].swap_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> swap_core_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].file_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> file_core_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].lstfile_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> lstfile_core_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].none +
SP -> heap_memory_pointer[i].swap_core +
SP -> heap_memory_pointer[i].file_core +
SP -> heap_memory_pointer[i].lstfile_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> total_2_pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Command
*/
x1 = sprintf (s256, "%s ",
SP -> heap_memory_pointer[i].u_psargs);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
break;
case 3:
/*
* Display Name & Pid
*/
pixel_list = determine_ps_mem_pixel (SP, i);
x1 = sprintf (s256,
"%9s %5d ",
SP -> heap_memory_pointer[i].name,
SP -> heap_memory_pointer[i].p_pid);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Virtual
*/
x1 = sprintf (s256, "%6d ",
SP -> heap_memory_pointer[i].virtual);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> virtual_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].none);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> none_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].swap);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> swap_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].file);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> file_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].lstfile);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> lstfile_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].zero);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> zero_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].fill);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> fill_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].iomap);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> iomap_pixel, s256);
x2 += x1 * FWIDTH;
#ifndef XSW32v5
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].window);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> window_pixel, s256);
x2 += x1 * FWIDTH;
#endif
/*
* Display Command
*/
x1 = sprintf (s256, "%s ",
SP -> heap_memory_pointer[i].u_psargs);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
break;
case 4:
/*
* Display Name & Pid
*/
pixel_list = determine_ps_mem_pixel (SP, i);
x1 = sprintf (s256,
"%9s %5d ",
SP -> heap_memory_pointer[i].name,
SP -> heap_memory_pointer[i].p_pid);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
/*
* Display Virtual
*/
x1 = sprintf (s256, "%6d ",
SP -> heap_memory_pointer[i].virtual);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> virtual_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].swap -
SP -> heap_memory_pointer[i].swap_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> swap_only_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].file -
SP -> heap_memory_pointer[i].file_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> file_only_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].lstfile -
SP -> heap_memory_pointer[i].lstfile_core);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> lstfile_only_pixel, s256);
x2 += x1 * FWIDTH;
/*
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].zero);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> zero_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].fill);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> fill_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].iomap);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> iomap_pixel, s256);
x2 += x1 * FWIDTH;
x1 = sprintf (s256, "%5d ",
SP -> heap_memory_pointer[i].window);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, pixel_list -> window_pixel, s256);
x2 += x1 * FWIDTH;
*/
/*
* Display Command
*/
x1 = sprintf (s256, "%s ",
SP -> heap_memory_pointer[i].u_psargs);
k = disp_info_text (window, display, gc, DrawAreaXYWH, x2, y,
pixmap, colorPSmem.pixel, s256);
x2 += x1 * FWIDTH;
break;
}
}
else
{
/*
fprintf(stdout,"Not drawing %d\n",i);
fprintf(stdout,"ps_mem_screen_mode = %d\n",
SP -> ps_mem_screen_mode);
fprintf(stdout,"total = %d\n",
SP -> heap_memory_pointer[i].total);
*/
}
if (pixel_list != NULL)
{
free (pixel_list);
pixel_list = NULL;
}
}
XSetForeground (display, gc, background);
XFillRectangle (display, pixmap, gc,
x, drawn_number * fheight,
SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].draw_width,
SP -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].draw_height);
SP -> ps_mem_button_change = 0;
}
/* vi: set tabstop=4 shiftwidth=4: */
/* end of psmem.c */